FROM golang:alpine as builder

WORKDIR /home/go/src/gin_vue_server

COPY . .

RUN go env -w GO111MODULE=on \
    && go env -w GOPROXY=https://goproxy.cn,direct \
    && go env -w CGO_ENABLED=0 \
    && go env -w GOOS=linux \
    && go env -w GOARCH=amd64 \
    && go env \
    && go mod tidy \
    && go build -o server .


FROM alpine:latest

LABEL MAINTAINER="1124045803@qq.com"

WORKDIR /home/go/src/gin_vue_server

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update && apk add ca-certificates && apk add tzdata
COPY --from=0 /home/go/src/gin_vue_server ./

EXPOSE 8080

ENTRYPOINT ["./server"]